/**
* 左边菜单
*/
<template>
  <el-menu :collapse="collapsed" collapse-transition router unique-opened class="el-menu-vertical-demo" background-color="#334157" text-color="#fff" active-text-color="#ffd04b">
    <div class="logobox">
      <img class="logoimg" src="../assets/img/logo.png" alt="">
    </div>

    <router-link to="/main">
      <el-menu-item index="Index">
        <template slot="title">
          <i class="el-icon-s-home"></i>
          <span slot="title">首页</span>
        </template>
      </el-menu-item>
    </router-link>

    <el-submenu v-for="menu in menuBeanList" :key="menu.menuid" :index="menu.menuName">
      <template slot="title">
        <i class="iconfont" :class="menu.icon"></i>&nbsp;
        <span>{{menu.menuName}}</span>
      </template>
      <el-menu-item-group v-if="menu.menuList != null">
        <el-menu-item v-for="chmenu in menu.menuList" :index="'/'+chmenu.url" :key="chmenu.menuId">
          <i class="iconfont" :class="chmenu.icon"></i>&nbsp;
          <span>{{chmenu.menuName}}</span>
        </el-menu-item>
      </el-menu-item-group>
    </el-submenu>
  </el-menu>
</template>

<script>
import menuApi from "../api/fastdfs/menu";
export default {
  name: 'leftnav',
  data() {
    return {
      collapsed: false,
      allmenu: [],
      menuBeanList:[],
    }
  },
  // 创建完毕状态(里面是操作)
  created() {
    this.$root.Bus.$on('toggle', value => {
      this.collapsed = !value
    })
    menuApi.getMenuByRoleId().then(response=>{
      this.menuBeanList = response.data.menuBeanList
    })

  }
}
</script>
<style>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 240px;
  min-height: 400px;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  border: none;
  text-align: left;
}
.el-menu-item-group__title {
  padding: 0px;
}
.el-menu-bg {
  background-color: #1f2d3d !important;
}
.el-menu {
  border: none;
}
.logobox {
  height: 40px;
  line-height: 40px;
  color: #9d9d9d;
  font-size: 20px;
  text-align: center;
  padding: 20px 0px;
}
.logoimg {
  height: 40px;
}
</style>
